﻿ #include "serialapp.h"
#include "com_manager.h"
#include "mhelper.h"
#include "topo_info.h"
#include "plug_info.h"
#include "formserial.h"

#include <QApplication>
#include <QFile>
#include <QTextCodec>
#include <nuf_bus_info.h>
#include <gpio_info.h>


#pragma execution_character_set("utf-8")

int main(int argc, char* argv[])
{
    SerialApp a(argc, argv);

	//设置中文编码
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
#if _MSC_VER
	QTextCodec* codec = QTextCodec::codecForName("GBK");
#else
	QTextCodec* codec = QTextCodec::codecForName("UTF-8");
#endif
	QTextCodec::setCodecForLocale(codec);
	QTextCodec::setCodecForCStrings(codec);
	QTextCodec::setCodecForTr(codec);
#else
	QTextCodec* codec = QTextCodec::codecForName("UTF-8");
	QTextCodec::setCodecForLocale(codec);
#endif


    //加载主题
    QFile styleFile(":/skin/darkstyle/darkstyle.qss");
  //  QFile styleFile(":/skin/vs_dark.qss");

	//QFile styleFile(":/styles/style.qss");



    a.setFont(QFont(QStringLiteral("Microsoft YaHei UI"), 10));//设置字体


    PlugInfo::loadSetting();
    NufBusSetting::loadSetting();

    TopoInfo::Instance()->loadSetting();

    com_manager::instance()->enum_com();
    foreach( QString comName , com_manager::instance()->comList)
        GpioSetting::init_gpio(comName);
 //  com_manager::instance()->openAllCom();

     // Form485 form485;
     // form485.show();

      FormSerial formSerial;
     formSerial.show();


    styleFile.open(QIODevice::ReadOnly);
    QString styles = styleFile.readAll();
    a.setStyleSheet(styles);
    styleFile.close();

    // MainWindow w;
    // w.show();
    return a.exec();
}
